package ioc

import (
	imGrpc "gitee.com/flycash/simple-im/internal/api/grpc"
	"github.com/ego-component/eetcd/registry"

	"github.com/ego-component/eetcd"

	"github.com/gotomicro/ego/core/econf"
)

func InitGrpc(server *imGrpc.MsgServer, reg *registry.Component, etcdClient *eetcd.Component) *imGrpc.Server {
	type cfg struct {
		Name       string `yaml:"name"`
		Addr       string `yaml:"addr"`
		DockerAddr string `yaml:"dockerAddr"`
	}
	var conf cfg
	err := econf.UnmarshalKey("server.grpc", &conf)
	if err != nil {
		panic(err)
	}
	return imGrpc.NewServer(conf.Name, conf.Addr, conf.DockerAddr, server, reg, etcdClient)
}
